import { Pipe, PipeTransform } from "@angular/core";

@Pipe({
  name: "imgUrl"
})
export class DataImgUrlPipe implements PipeTransform {
  transform(value: string, ...args) {
    return this.dataBase(value, ...args);
  }

  dataBase(value, ...key) {
  
    let url = eval("(" + localStorage.getItem("url") + ")");
    if (value == "" || value == null || value == undefined) {
      if (key[1] == "" || key[1] == null || key[1] == undefined) {
        key[1] = "banner1";
      }
      url = "assets/imgs/img/" + key[1] + ".png";
    } else {
      if (key[0] == 'base64') {
        url = "data:image/png;base64," + value;
      } else {
        url = url[key[0]] + value
      }
    }
    if (key[1] == "backImg") {
      if (key[0] == 'base64'){
        url = "url(" + url + ")";
      }else{
        url = "url(" + url + ")";
      }
     // this.backImg(url);
    }
    return url;
  }


}